import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/Login.vue'
import Home from '../components/Home.vue'
import Main from '../components/Main.vue'
import Users from '../components/other/Users.vue'
import Constatnt from '../components/other/Constatnt.vue'
import Department from '../components/other/Department.vue'
import RegistLevel from '../components/other/RegistLevel.vue'
import Settle from '../components/other/Settle.vue'
import Dise from '../components/other/Dise.vue'
import FmedItem from '../components/other/FmedItem.vue'
import Scheduling from '../components/scheduling/Scheduling.vue'
import Rule from '../components/scheduling/Rule.vue'


Vue.use(VueRouter)

  const routes = [
    {
      path:'/',
      redirect:'/login'
    },
    {
      path:'/login',
      component:Login
    },
    {
      path:'/home',
      component: Home,
      redirect:'/main',
      children:[
        {path:'/main',component:Main},
        {path:'/user',component:Users},
        {path:"/constatnt",component:Constatnt},
        {path:"/department",component:Department},
        {path:"/registLevel",component:RegistLevel},
        {path:"/settle",component:Settle},
        {path:"/dise",component:Dise},
        {path:"/fmedItem",component:FmedItem},
        {path:"/scheduling",component:Scheduling},
        {path:"/rule",component:Rule}
      ]
    }
  ]

//解决重复路由报异常的问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(error=> error)
}

const router = new VueRouter({
  routes
})

export default router